package com.ti.andon.workflow.dao;
// default package

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;

import com.ti.andon.persistent.JbpmAdProcessLog;
import com.ti.andon.workflow.dao.base.BaseHibernateDAO;

/**
 	* A data access object (DAO) providing persistence and search support for JbpmAdProcessLog entities.
 			* Transaction control of the save(), update() and delete() operations 
		can directly support Spring container-managed transactions or they can be augmented	to handle user-managed Spring transactions. 
		Each of these methods provides additional information for how to configure it for the desired type of transaction control. 	
	 * @see .JbpmAdProcessLog
  * @author MyEclipse Persistence Tools 
 */

public class JbpmAdProcessLogDAO_bak extends BaseHibernateDAO  {
    private static final Log log = LogFactory.getLog(JbpmAdProcessLogDAO_bak.class);
	//property constants
	public static final String PROCESS_INSTANCE_ID = "processInstanceId";
	public static final String BUSINESS_KEY = "businessKey";
	public static final String USER_ID = "userId";
	public static final String PROCESS_TYPE = "processType";
	public static final String PROCESS_TIME = "processTime";
	public static final String COMMENTS = "comments";
	public static final String DEPARTMENT_ID = "departmentId";
	public static final String STATUS = "status";
	public static final String DELEGATOR_ID = "delegatorId";
	public static final String PROCESS_NAME = "processName";



    
    public void save(JbpmAdProcessLog transientInstance) {
        log.debug("saving JbpmAdProcessLog instance");
        try {
            getSession().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(JbpmAdProcessLog persistentInstance) {
        log.debug("deleting JbpmAdProcessLog instance");
        try {
            getSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public JbpmAdProcessLog findById( java.lang.Long id) {
        log.debug("getting JbpmAdProcessLog instance with id: " + id);
        try {
            JbpmAdProcessLog instance = (JbpmAdProcessLog) getSession()
                    .get("JbpmAdProcessLog", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(JbpmAdProcessLog instance) {
        log.debug("finding JbpmAdProcessLog instance by example");
        try {
            List results = getSession()
                    .createCriteria("JbpmAdProcessLog")
                    .add(Example.create(instance))
            .list();
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }    
    
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding JbpmAdProcessLog instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from JbpmAdProcessLog as model where model." 
         						+ propertyName + "= ?";
         Query queryObject = getSession().createQuery(queryString);
		 queryObject.setParameter(0, value);
		 return queryObject.list();
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}

	public List findByProcessInstanceId(Object processInstanceId
	) {
		return findByProperty(PROCESS_INSTANCE_ID, processInstanceId
		);
	}
	
	public List findByBusinessKey(Object businessKey
	) {
		return findByProperty(BUSINESS_KEY, businessKey
		);
	}
	
	public List findByUserId(Object userId
	) {
		return findByProperty(USER_ID, userId
		);
	}
	
	public List findByProcessType(Object processType
	) {
		return findByProperty(PROCESS_TYPE, processType
		);
	}
	
	public List findByProcessTime(Object processTime
	) {
		return findByProperty(PROCESS_TIME, processTime
		);
	}
	
	public List findByComments(Object comments
	) {
		return findByProperty(COMMENTS, comments
		);
	}
	
	public List findByDepartmentId(Object departmentId
	) {
		return findByProperty(DEPARTMENT_ID, departmentId
		);
	}
	
	public List findByStatus(Object status
	) {
		return findByProperty(STATUS, status
		);
	}
	
	public List findByDelegatorId(Object delegatorId
	) {
		return findByProperty(DELEGATOR_ID, delegatorId
		);
	}
	
	public List findByProcessName(Object processName
	) {
		return findByProperty(PROCESS_NAME, processName
		);
	}
	

	public List findAll() {
		log.debug("finding all JbpmAdProcessLog instances");
		try {
			String queryString = "from JbpmAdProcessLog";
	         Query queryObject = getSession().createQuery(queryString);
			 return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
    public JbpmAdProcessLog merge(JbpmAdProcessLog detachedInstance) {
        log.debug("merging JbpmAdProcessLog instance");
        try {
            JbpmAdProcessLog result = (JbpmAdProcessLog) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(JbpmAdProcessLog instance) {
        log.debug("attaching dirty JbpmAdProcessLog instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(JbpmAdProcessLog instance) {
        log.debug("attaching clean JbpmAdProcessLog instance");
        try {
            getSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
}